<?php
/**
 * Class LoginHelper
 */
class LoginHelper {
    static public  $user_info;
    static function login($data,$api_key = 'kwinbon.grain'){
        $model_sys = Controller::createMode('db_sys','t_sys_app');
        $app = $model_sys->getOne(array('app_key'=>$api_key));
        $model = Controller::createMode('db_sys_26_'.$app['app_id'],'t_26_suppliers');
        $sql = "SELECT *
                FROM t_26_suppliers
                WHERE (login_username = '{$data[account]}'
                or s_name = '{$data[account]}'
                or s_tel = '{$data[account]}')
                AND login_password = '{$data[password]}'";
        $list =  $model->execute($sql, true, true);
        return $list[0];
    }
    public static function getUserId(){
        $user_id = session::get(PassportController::getUserIdKey());
        return $user_id?$user_id:0;
    }
    public static function getUserName(){
        $user_name = session:: get('account_branch_name');
        return $user_name?$user_name:"";
    }
    public static function getMobile(){
        return cookie::get(PassportController::getUserMobileKey());
    }
}